package com.javabasic.algorithm.leetcode;

/**
 * @author mir.xiong
 * @version 1.0
 * @description
 * @see [1716. Calculate Money in Leetcode Bank](https://leetcode-cn.com/problems/calculate-money-in-leetcode-bank/)
 * @since Created by work on 2022/1/15 3:38 下午
 */
public class Calculate_Money_In_Leetcode_Bank {

    public int totalMoney(int n) {
        int tag = n % 7, week = n / 7;
        int weekResult = 0;
        if (week > 0) {
            weekResult += ((1 + 7) * 7 * week / 2) + (week - 1) * week * 7 / 2;
        }
        weekResult += (week+1 + week+tag)*tag/2;
        return weekResult;
    }
}
